package com.lxt.ScreencastGallery;

import java.io.File;

/**
 * 媒体文件数据模型
 */
public class MediaItem2 {
    private File file;
    private String name;
    private boolean isVideo;
    private long size;
    private long lastModified;

    public MediaItem2(File file) {
        this.file = file;
        this.name = file.getName();
        this.isVideo = isVideoFile(file.getName());
        this.size = file.length();
        this.lastModified = file.lastModified();
    }

    public File getFile() {
        return file;
    }

    public void setFile(File file) {
        this.file = file;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isVideo() {
        return isVideo;
    }

    public void setVideo(boolean video) {
        isVideo = video;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

    public long getLastModified() {
        return lastModified;
    }

    public void setLastModified(long lastModified) {
        this.lastModified = lastModified;
    }

    /**
     * 判断是否为视频文件
     */
    private boolean isVideoFile(String fileName) {
        String extension = AppConfig.getFileExtension(fileName);
        return AppConfig.isSupportedVideoFormat(extension);
    }
}
